package io.terminus.lego.shinda.web.security.phone.token

import org.springframework.security.authentication.AbstractAuthenticationToken
import org.springframework.security.core.GrantedAuthority

/**
 * 特殊用户认证信息Token
 * @author wangmeng
 * @date 2018/4/28
 */
class SpecialUserLoginAuthenticationToken : AbstractAuthenticationToken {
    private val principal: Any
    private val credentials: Any
    private val userType: String

    constructor(principal: Any, credentials: Any, userType: String) : super(null) {
        this.principal = principal
        this.credentials = credentials
        this.userType = userType
        this.isAuthenticated = false
    }

    constructor(principal: Any, credentials: Any, authorities: Collection<GrantedAuthority>, userType: String) : super(authorities) {
        this.principal = principal
        this.credentials = credentials
        this.userType = userType
        this.isAuthenticated = true

    }

    override fun getCredentials(): Any {
        return credentials
    }

    override fun getPrincipal(): Any {
        return principal
    }

    fun getUserType(): String {
        return userType
    }

}